fix(claude): derive context token budget from the Claude model in Claude Code mode#390
Open
herikwebb wants to merge 1 commit into
Open
fix(claude): derive context token budget from the Claude model in Claude Code mode#390herikwebb wants to merge 1 commit into
herikwebb wants to merge 1 commit into
Conversation
…ude Code mode In Claude Code mode ai_service_manager.chat_model reflects the user's most recent non-Claude provider selection and is None on a Claude-only setup. The attachment budget fell through to the legacy 100-token floor (80 tokens after the 0.8 factor), which silently skipped cell-output context and dropped every attachment after the first via the budget break in on_message. Resolve the budget from the configured Claude model instead, via model_info_from_id (200K-window fallback for unknown or default model ids).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In Claude Code mode,
ai_service_manager.chat_modelreflects the user's most recent non-Claude provider selection and isNoneon a Claude-only setup. The attachment token budget inon_messagefell through to the legacy 100-token floor (80 tokens after the 0.8 factor), which:remaining_token_budget <= 0break.Change
_resolve_context_token_limithelper: in Claude Code mode the budget comes from the configured Claude model viamodel_info_from_id(200K-window fallback for unknown/default ids); other modes keep the existing behavior.on_messagetest proving a >80-token output context survives on a Claude-only setup.Testing
Full Python suite passes. Manually verified in JupyterLab on a Claude-only setup: attaching a 34-line cell output (well over the old 80-token budget) via "Ask about this output" and asking the agent to echo a sentinel marker + a derived value returned the correct
SENTINEL-7F3A / col_sum_A=1198— i.e. the full output reached the model. Onmainthe same attachment comes backNO CONTEXT.